﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;
using NativeWifi;
using System.Threading;
using System.Runtime.InteropServices;


namespace HGY.NetworkInterfaceManager
{
    static class Program
    {
        [DllImport("user32.dll")]
        public static extern int ShowWindow(IntPtr hwnd, int nCmdShow);
        [DllImport("user32.dll")]
        public static extern bool SetForegroundWindow(IntPtr hWnd);


        public static Mutex mutex;
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            bool createdNew = false;
            mutex = new Mutex(true, "Global\\gyhu_NetworkInterfaceManager", out createdNew);
            if (createdNew)
            {
                mutex.ReleaseMutex();
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new FrmMain());
            }
            else
            {
                IntPtr hwind = new IntPtr(XmlConfig.Instance.MainHandler);
                ShowWindow(hwind, 5);
                SetForegroundWindow(hwind);
            }
        }

    }
}